﻿CREATE PROCEDURE [dbo].[WaitForAndReceiveNextMessage]
	@QueueName servicenametype
AS
	DECLARE @sql nvarchar(400)
	
	SET @sql = N'WAITFOR (RECEIVE TOP (1)  CAST(message_body AS Xml)  FROM [' + @QueueName + N']), TIMEOUT 5000'

	EXEC sp_executesql @sql